import os
import pandas as pd


if __name__ == '__main__':
    path = "result/"
    pd_all = pd.read_csv(os.path.join(path, "test_results.tsv") ,sep='\t',header=None)

    data = pd.DataFrame(columns=['polarity'])
    print(pd_all.shape)

    for index in pd_all.index:
        n1 = pd_all.loc[index].values[0]
        n2 = pd_all.loc[index].values[1]
        n3 = pd_all.loc[index].values[2]
        n4 = pd_all.loc[index].values[3]
        n5 = pd_all.loc[index].values[4]
        n6 = pd_all.loc[index].values[5]
        n7 = pd_all.loc[index].values[6]
        n8 = pd_all.loc[index].values[7]
        n9 = pd_all.loc[index].values[8]
        n10 = pd_all.loc[index].values[9]

        if max(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) == n1:
            # data.append(pd.DataFrame([index, "neutral"],columns=['id','polarity']),ignore_index=True)
            data.loc[index+1] = ["0"]
        elif max(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) == n2:
            #data.append(pd.DataFrame([index, "positive"],columns=['id','polarity']),ignore_index=True)
            data.loc[index+1] = ["1"]
        elif max(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) == n3:
            #data.append(pd.DataFrame([index, "positive"],columns=['id','polarity']),ignore_index=True)
            data.loc[index+1] = ["2"]
        elif max(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) == n4:
            #data.append(pd.DataFrame([index, "positive"],columns=['id','polarity']),ignore_index=True)
            data.loc[index+1] = ["3"]
        elif max(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) == n5:
            #data.append(pd.DataFrame([index, "positive"],columns=['id','polarity']),ignore_index=True)
            data.loc[index+1] = ["4"]
        elif max(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) == n6:
            #data.append(pd.DataFrame([index, "positive"],columns=['id','polarity']),ignore_index=True)
            data.loc[index+1] = ["5"]
        elif max(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) == n7:
            #data.append(pd.DataFrame([index, "positive"],columns=['id','polarity']),ignore_index=True)
            data.loc[index+1] = ["6"]
        elif max(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) == n8:
            #data.append(pd.DataFrame([index, "positive"],columns=['id','polarity']),ignore_index=True)
            data.loc[index+1] = ["7"]
        elif max(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) == n9:
            #data.append(pd.DataFrame([index, "positive"],columns=['id','polarity']),ignore_index=True)
            data.loc[index+1] = ["8"]
        else:
            #data.append(pd.DataFrame([index, "negative"],columns=['id','polarity']),ignore_index=True)
            data.loc[index+1] = ["9"]
        #print(negative_score, positive_score, negative_score)

    data.to_csv(os.path.join(path, "pre_sample.tsv"),sep = '\t')
    #print(data)
